﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class WorkClassQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCreateDate;
        protected DropDownList ddlCreatedBy;
        protected DropDownList ddlDescr;
        protected DropDownList ddlWorkClassID;
        protected HtmlForm F2660;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlImage img2;
        protected Label lblCreateDate;
        protected Label lblCreatedBy;
        protected Label lblDescr;
        protected Label lblTitle;
        protected Label lblWorkClassID;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCreateDate;
        protected TextBox txtCreateDate2;
        protected TextBox txtCreatedBy;
        protected TextBox txtDescr;
        protected TextBox txtWorkClassID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("WorkClassList.aspx?action={0}&from='list'", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("WorkClassList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.hdnActionID.Value = base.Request.QueryString["action"].ToString();
            }
        }

        private void LoadDLL()
        {
            base.InitQueryDDL(this.ddlWorkClassID, 0);
            base.InitQueryDDL(this.ddlDescr, 0);
            base.InitQueryDDL(this.ddlCreatedBy, 0);
            base.InitQueryDDL(this.ddlCreateDate, 1);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDLL();
                this.LoadData();
            }
        }

        public string CreateDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreateDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreateDate.Text.Trim(), this.ddlCreateDate.SelectedValue, this.txtCreateDate2.Text.Trim(), "CreateDate");
                }
                return "";
            }
        }

        public string CreatedBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedBy.Text.Trim(), this.ddlCreatedBy.SelectedValue);
                }
                return "";
            }
        }

        public string Descr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDescr.Text.Trim(), this.ddlDescr.SelectedValue);
                }
                return "";
            }
        }

        public string WorkClassID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtWorkClassID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtWorkClassID.Text.Trim(), this.ddlWorkClassID.SelectedValue);
                }
                return "";
            }
        }
    }
}

